﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZF.BLL;
using GCELibrary.Current;

namespace ZF.WS.UserControls.Index
{
    public partial class AdsArea : System.Web.UI.UserControl
    {
        public string Key { get; set; }
        public Model.AD_Img Ads { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var dc = SiteInfo.CreateDBDataContext())
            {
                List<Model.AD_Img> list = null;
 
                var cacheKey = "AdsArea";
                var obj = HttpCache.GetCache(cacheKey);
                if (obj != null)
                {
                    list = obj as List<Model.AD_Img>;
                }
                else
                {
                    list = new List<Model.AD_Img>();

                    list=dc.AD_Img.ToList();
                    SiteInfo.Instance.SetPageCache(cacheKey, list);
                    //SiteInfo.Instance.SetCache(cacheKey,list, SiteInfo.Instance.SystemConfig.DefCacheTimeSpan);
                }
                Ads = list.FirstOrDefault(p => p.AppKey == Key);
                if (Ads == null)
                    Ads = new ZF.Model.AD_Img();
                


            }
        }
    }
}